package cn.texous.demo.dgs.config;

import cn.texous.util.commons.util.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 启动后请求路由接口，解决首次网关超时问题（在过滤器中请求网关，首次超时问题）
 *
 * @author Showa.L
 * @since 2019/7/16 10:57
 */
@Component
public class MyInitRunner implements ApplicationRunner {

    @Autowired
    private OauthProperties oauthProperties;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        String url = String.format("%s%s", oauthProperties.getBaseUrl(),
                oauthProperties.getAuthorizationUri());
        MessageUtil.HttpsRequestParam param = MessageUtil.HttpsRequestParam.builder()
                .requestMethod("POST")
                .requestUrl(url)
                .build();
        MessageUtil.commonRequest(param);
    }

}
